﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Gencode.PrsWeb
{
    public partial class Personalstamm : Gencode.Web.Common.WebPage
	{
		Gencode.PrsWeb.App.User user;

		protected void Page_Load(object sender, EventArgs e)
		{
			user = Session["USERRIGHTS"] as Gencode.PrsWeb.App.User;
			if (user == null)
				Response.Redirect("Login.aspx");

            personModule.Controls.Add(LoadControl("Modules\\PersonEdit.ascx"));

            InitControls();
		}

		private void InitControls()
		{
			personenGrid.DataSource = Gencode.PrsCommon.Data.Person.DataGenerator.GetPersonen(user.Mandid,Gencode.PrsCommon.Data.Person.DataGenerator.PersonTyp.Stammperson);
			personenGrid.DataBind();
		}

		protected void personenGrid_ItemDataBound(object sender, DataGridItemEventArgs e)
		{

		}

		protected void personenGrid_ItemCommand(object source, DataGridCommandEventArgs e)
		{
            if (e.CommandSource.ToString() != string.Empty)
            {
                string test1 = ((TableCell)e.Item.Controls[1]).Text;
                string test2 = ((TableCell)e.Item.Controls[2]).Text;
                string test3 = ((TableCell)e.Item.Controls[3]).Text;
                string test4 = ((TableCell)e.Item.Controls[4]).Text;
                //string test5 = e.Item.FindControl("prsid").ToString();
                //string test6 = (()e.Item.Controls[0]).Text;
                Response.Redirect("Personalstamm.aspx?PRSID=" + e.CommandSource);
            }
		}
	}
}
